package com.zxmr.domain.service;

import java.sql.SQLException;
import java.util.List;

import com.zxmr.CommonInit;
import com.zxmr.db.DBManager;
import com.zxmr.domain.SurgeryRecord;

public class SurgeryRecordService {

	DBManager db = CommonInit.getDBManager();
	
	public boolean addSurgeryRecord(SurgeryRecord surgeryRecord)
	{
		try {
			db.getMapper().insert("surgeryRecord.add",surgeryRecord);
			return true;
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return false;
	}
	public SurgeryRecord querySurgeryRecord(int id)
	{
		try
		{
			return (SurgeryRecord)db.getMapper().queryForObject("surgeryRecord.queryFullField",id);
		}catch(SQLException e){
			e.printStackTrace();
		}
		return null;
	}
	public boolean updateSurgeryRecord(SurgeryRecord surgeryRecord)
	{
		try {
			db.getMapper().update("surgeryRecord.update", surgeryRecord);
			return true;
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return false;
	}
	@SuppressWarnings("unchecked")
	public List<SurgeryRecord> querySurgeryRecordPagination(SurgeryRecordSearchBean bean)
	{
		try {
			return (List<SurgeryRecord>)db.getMapper().queryForList("surgeryRecord.searchPagination", bean);
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return null;
	}
	public int querySurgeryRecordPaginationCount(SurgeryRecordSearchBean bean)
	{
		try {
			return (Integer)db.getMapper().queryForObject("surgeryRecord.findCountPagination", bean);
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return -1;
	}
}
